home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
ansippv2.zip
/
READ.ME
< prev
next >
Wrap
Text File
|
1988-09-21
|
23KB
|
460 lines
Thanks for your gratifying response to my article in Computer Language, July
1988, titled "Using Tomorrow's C Standard Today". This disk contains the
latest source and executable code for the ANSI-Conforming C Language
Preprocessor presented there. This is contained in the archive PPV2.ARC.
Don Kneller's NDMAKE
Also included is Don Kneller's NDMAKE utility, which is used to maintain the
preprocessor. If you didn't have a MAKE utility before, you now have one of
the best. If you decide to use it, be sure to support Don's efforts by
becoming a legal user of NDMAKE. This is contained in the archive
NDMAKE43.ARC.
I have included NDMAKE at no charge. Any charge for this disk is for the
preprocessor, not NDMAKE.
Don also markets a commercial version with even more features, called OPUS
Make. It is available from:
OPUS Software
D.G. Kneller and J.F. Thomason
1032 Irving Street
Suite 439
San Francisco, CA 94122
Phil Katz's PKPAK
Both archives may be unpacked using Phil Katz's unsurpassed PKPAK (formerly
PKARC) utility, which is contained in the self-extracting archive PK361.EXE.
Simply running PK361.EXE will unpack Phil's program and documentation into
the current directory. Again, if you find PKPAK useful, please register with
Phil as a legal user.
(Phil and his company PKWARE have recently been the target of a lawsuit by
SEA, with whose ARC.EXE program PKPAK is compatible. You may read the text of
their settlement and decide for yourself, but many people think that Phil was
treated unfairly. By providing us with a fast and useful tool, he exposed
himself to this kind of action, and so we all owe him a great deal.)
I have included PKPAK at no charge. Any charge for this disk is for the
preprocessor, not PKPAK.
Revision Control System
I hope that you will learn from examining this source code. I also hope that
you will make changes to it, so that it better suits your needs. If you do,
you will probably find a revision control system as useful as I do. One of
the most affordable, as well as fast and capable, is TLIB, available from:
Burton Systems Software
P.O. Box 4156
Cary, NC 27519-0156
(919) 469-3068
TLIB allows you to keep track of your revisions as you make them, and also to
merge my changes into your own if I send you a new version. Once you start
using a revision control system, you just can't stop.
The ANSI Draft
Anyone who seriously wants to use the preprocessor should obtain a copy of the
ANSI draft from the address in PP.MAN. Unfortunately, its expensive, but
there's no other way to learn the new features and behavior.
The comments in this source code often refer to sections in the ANSI draft.
Those comments, and the entire preprocessor, are based on the draft dated
January 11, 1988, which is already outdated. If you obtain the ANSI draft
today, you will receive a later revision. The section numbers should be
close. Whether the behavior is close depends on the changes they have made.
The Preprocessor
The following files are included in PPV2.ARC:
ANSI.DAT ANSI "Torture test" examples
ASSERT.H An ANSI assert() macro
ERROR.C Error message function.
ERROR.H Error message function.
MAKE.INI Use with Don Kneller's NDMAKE
MAKEFILE Use with Don Kneller's NDMAKE
MEMORY.C Memory allocation functions.
MEMORY.H Memory allocation functions.
PP.C Standalone preprocessor.
PP.EXE Standalone preprocessor.
PP.H Definitions for PP.LIB.
PP.MAN Brief description of usage
PPCHAR.C Handle trigraph translation.
PPDIRECT.C Preprocessor directives.
PPIFS.C #if and related directives.
PPMACRO.C #define #undef Macro replacement
PPTOK.C Tokenizer.
SYMTAB.C Hashed symbol table functions.
SYMTAB.H Hashed symbol table functions.
VERS2.H A little file used by ANSI.DAT.
Differences From Version 1
The following are a list of differences between Version 1 and Version 2 of the
preprocessor. Any user who has made changes to the Version 1 source code may
contact me to receive a full TLIB revision history of my changes. This would
allow that user to use TLIB to merge my changes with his or her own.
The preprocessor now runs about twice as fast, due to compilation with the
Watcom C Compiler.
The source code itself is closer to ANSI-Conformance, although it still fails
to conform in many places. The primary change is to use prototype function
declarations. Note that the this comment applies to the source code itself,
not to the function of the program. It has always been intended that the
program functions as an ANSI-Conforming C Language Preprocessor. It is
possible for non-conforming C source code to fit that function.
A bug was corrected that produced an incorrect macro replacement or a
diagnostic when any macro invocation contained a parameter that began with a
left parenthesis. For example, the input:
#define str(x) / #x /
#define cat(x, y) | #x #y |
These work OK:
str(test)
cat(left, right)
These work not OK:
str((test))
cat((left), (right))
produces the following output:
These work OK:
/ "test" /
| "leftright" |
These work not OK:
/ "(test" /)
12: Too few macro arguments.
, (right))
A bug was corrected that produced garbage upon certain invalid #include
directives.
#pragma directives are now optionally passed through to the output. Within
passed-through #pragma directives, macros may be replaced, optionally. If
#pragma pass-through is disabled (as by default), #pragma directives are
silently ignored and discarded. This change allows the preprocessor to work
correctly with compilers such as Watcom, to whom #pragma directives are
important. It also allows the preprocessor to correctly handle input that
contains #pragma directives; previously, only the simplest #pragma directives
were discarded without complaint.
The preprocessor now scrupulously frees all dynamically allocated memory.
Previously, memory allocated for the symbol table, and certain other data, was
never freed, because it is used throughout the execution of the preprocessor.
This change is only for my peace of mind. It may be more significant to
others that write programs that call the preprocessor library: a new function,
PPTerminate(), ensures that all memory allocated by the library is freed.
Dynamic memory allocation is now performed via malloc() and free().
Previously, the preprocessor library chose between malloc() and sbrk()
depending on the size of the memory to be allocated. This was important under
the Lattice compiler, whose malloc() and free() are excruciating. There is no
apparent advantage under Watcom, and sbrk() caused other problems.
The NDEBUG macro in ASSERT.H worked backwards. That is, defining NDEBUG
enabled the assert() macro, instead of disabling it as it should.
The __DATE__ and __TIME__ predefined macros are now replaced with the current
date and time, instead of a canned date and time.
Other minor changes to the source code and comments.
The Compiler
This version may be compiled using the Watcom C Compiler version 6.5. I have
also compiled it with various versions of Microsoft C, and it works. More on
the Watcom compiler below.
If you don't use the Watcom compiler, you can probably use your favorite
compiler instead without too much trouble, provided your compiler can handle
prototype function declarations. (This elim